import asyncio
import aiohttp


def download_completed_callback(task_obj):
    print("下载的内容为:", task_obj.result())


async def qfang():
    for i in range(1, 11):
        url = "https://shenzhen.qfang.com/sale/f%s" % (i)
        async with aiohttp.ClientSession() as session:
            async with session.get(url) as r:
                return await r.text()


async def main():
    # 创建多个Task，且添加回调函数
    task_qfang = asyncio.create_task(qfang())
    task_qfang.add_done_callback(download_completed_callback)

    # 等待下载
    await asyncio.wait(task_qfang)


if __name__ == '__main__':
    asyncio.run(main())
